package com.smh.a03exerciseDemo1;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
import java.util.stream.Collectors;

public class Test2 {
    public static void main(String[] args) {

        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list,"zhangsan,23","lisi,24","wangwu,25");

        //筛选大于等于24岁的,并保留到map集合

        Map<String, Integer> collect = list.stream().filter(s -> {
            String[] split = s.split(",");
            int i = Integer.parseInt(split[1]);
            return i >= 24;
        }).collect(Collectors.toMap(s -> {
            return s.split(",")[0];
        }, s -> {
            return Integer.parseInt(s.split(",")[1]);
        }));

        System.out.println(collect);


    }
}
